<style>
  .picImg {
    width: 40px;
    height: 40px;
  }
</style>
<template>
  <div class="app-container">
    <div class="filter-container">
      <el-date-picker
        v-model="dotext.startTime"
        type="datetime"
        placeholder="查询开始日期"
        value-format="yyyy-MM-dd HH:mm:ss">
      </el-date-picker>
      -
      <el-date-picker
        v-model="dotext.endTime"
        type="datetime"
        placeholder="查询结束日期"
        value-format="yyyy-MM-dd HH:mm:ss">
      </el-date-picker>
      <el-input v-model="dotext.agentID" placeholder="保公司/权益服务商ID" style="width: 300px"/>
      <el-input v-model="dotext.factoringID" placeholder="保理公司ID" style="width: 300px"/>
      <el-button @click="getInput">确定</el-button>
    </div>
    <!--&lt;!&ndash; 查询和其他操作 &ndash;&gt;-->
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row
              @row-click="detail">

      <el-table-column align="center" min-width="100" label="回款金额" prop="amount"/>
      <el-table-column align="center" min-width="100" label="回款时间" prop="repayTime"/>
      <el-table-column align="center" min-width="100" label="备注" prop="remark"/>
      <el-table-column align="center" min-width="100" label="表单ID" prop="id"/>
      <el-table-column align="center" min-width="100" label="表单编号" prop="formNo"/>
      <el-table-column align="center" min-width="100" label="保险公司ID" prop="insuranceID"/>
      <el-table-column align="center" min-width="100" label="保代公司ID" prop="insuragentID"/>
      <el-table-column align="center" min-width="100" label="保理公司ID" prop="factoringID"/>
      <el-table-column align="center" min-width="100" label="保单总数" prop="billCount"/>
      <el-table-column align="center" min-width="100" label="手续费总额" prop="amount"/>
      <el-table-column align="center" min-width="100" label="上传备注" prop="remarkUp"/>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize"
                @pagination="getList"/>
    <el-dialog :visible.sync="editDialogVisible" title="明细列表">
      <el-table v-loading="listLoading1" :data="list1" element-loading-text="正在查询中。。。" border fit highlight-current-row>

        <el-table-column align="center" min-width="100" label="表单ID" prop="id"/>
        <el-table-column align="center" min-width="100" label="保单号或合同号" prop="billNo"/>
        <el-table-column align="center" min-width="100" label="保单金额" prop="billAmount"/>
        <el-table-column align="center" min-width="100" label="代理手续费" prop="fee"/>
        <el-table-column align="center" min-width="100" label="代理人身份证号" prop="agentID"/>
        <el-table-column align="center" min-width="100" label="代理人编码" prop="agentNo"/>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="editDialogVisible = false">确定</el-button>
        </div>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="editDialogVisible = false">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {doGet, doPost} from '@/api'
  import {cities} from '@/utils/base'
  import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

  export default {
    name: 'bank',
    components: {Pagination},
    filters: {},
    data() {
      return {
        pickerOptions: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date());
            }
          }, {
            text: '昨天',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit('pick', date);
            }
          }, {
            text: '一周前',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', date);
            }
          }]
        },
        list: [],
        list1: [],
        total: 0,
        listLoading: true,
        listLoading1: true,
        listQuery: {
//                    page: 1,
//                    pageSize: 20
          serviceID: ''
        },
        dotext: {
          startTime: undefined,
          endTime: undefined,
          agentID: undefined,
          factoringID: undefined,
        },
        editForm: {
          id: undefined,
          billNo: undefined,
          billAmount: undefined,
          fee: undefined,
          agentID: undefined,
          agentNo: undefined,
        },
        editDialogVisible: false,
      }
    },
    created() {
      this.getList()
    },
    methods: {
      getList() {
        this.listLoading = true
        doGet('repaysearch.html?op=list', this.dotext).then(response => {
          this.list = response.rows
          this.total = response.rows.length
          this.listLoading = false
        }).catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
      },
      getInput() {
        this.getList()
      },
      detail(row) {
        this.editDialogVisible = true
        this.listLoading1 = true
//        console.log(row.id)
        doGet('bxagentfee.html?op=billlist', {id:row.id}).then(response => {
          console.log(response);
          this.list1 = response.rows
          this.listLoading1 = false
//          this.editForm.id = response.rows.id;
//          this.editForm.billNo = response.rows.billNo;
//          this.editForm.billAmount = response.rows.billAmount;
//          this.editForm.fee = response.rows.fee;
//          this.editForm.agentID = response.rows.agentID;
//          this.editForm.agentNo = response.rows.agentNo
        }).catch(() => {
          this.list = [];
          this.total = 0;
          this.listLoading1 = false
        })
      },
    }
  }
</script>
